package demo1;

import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();

        //1. 字符串的分割    split()

        // String[] ss = str.split(" ");
        // int len = ss[ss.length-1].length();

        // System.out.println(len);

        //2. 找到最后一个空格的下标 ，然后截取空格后的字符串，然后求长度  lastindexOf  subString()
        int index = str.lastIndexOf(" ");
        int len = str.substring(index+1).length();
        System.out.println(len);
    }


    public static void main19(String[] args) {
        StringBuilder stringBuilder = new StringBuilder("abcdef");
        stringBuilder.insert(3,"haha");
        //stringBuilder.reverse();
        System.out.println(stringBuilder);
    }

    public static void main18(String[] args) {


        long start = System.currentTimeMillis();//毫秒
        String s = "";
        for(int i = 0; i < 10000; ++i){
            s += i;
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);


        start = System.currentTimeMillis();
        StringBuffer sbf = new StringBuffer("");
        for(int i = 0; i < 10000; ++i){
            sbf.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end - start);


        start = System.currentTimeMillis();
        StringBuilder sbd = new StringBuilder();
        for(int i = 0; i < 10000; ++i){
            sbd.append(i);
        }
        end = System.currentTimeMillis();
        System.out.println(end - start);

    }
    public static void main16(String[] args) {
        String s = "hello";
        s += " world";//s = s + ....
        System.out.println(s);
    }

    public static void main17(String[] args) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("hello");
        stringBuilder.append(" world");
        String ret = stringBuilder.toString();
        System.out.println(ret);
    }

    public static void main15(String[] args) {
        String s = "abcd";

        final char[] array = {'a','b','c'};
        array[0] = 'g';

        // array = new char[10];


    }
    public static void main14(String[] args) {
        String s = "  abc d e f g    ";
        System.out.println(s);

        String s2 = s.trim();//只会去除  左右两边的空格
        System.out.println(s2);

    }


    public static void main13(String[] args) {
        String s = "abcdef";
        String s2 = s.substring(2,4);//[)
        System.out.println(s2);
    }

    public static void main12(String[] args) {
        String s = "name=zhangsan&age=10";
        //返回值  是数组
        String[] strings = s.split("=|&");
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }
    }

    public static void main11(String[] args) {
        String s = "ab\\cd\\ef";
        //System.out.println(s);

        String[] strings = s.split("\\\\");
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }
    }

    public static void main10(String[] args) {
        String s = "192.168.0.1";
        String[] strings = s.split("\\.");
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }
    }

    public static void main9(String[] args) {
        //"name=zhangsan&age=10"
        String s = "name=zhangsan&age=10";
        //返回值  是数组
        String[] strings = s.split("&");
        for (int i = 0; i < strings.length; i++) {
            //strings[i] = name=zhangsan
            //strings[i] = age=10
            //System.out.println(strings[i]);
            String[] ss = strings[i].split("=");
            for (int j = 0; j < ss.length; j++) {
                System.out.print(ss[j]+" ");
            }
            System.out.println();
        }
    }

    public static void main8(String[] args) {
        String s = "ababcabcd";
        String tmp = s.replace('a','k');
        System.out.println(tmp);

        tmp = s.replace("ab","uuu");
        System.out.println(tmp);

        tmp = s.replaceFirst("ab","ooo");
        System.out.println(tmp);

        tmp = s.replaceAll("ab","ooo");
        System.out.println(tmp);
    }

    public static void main7(String[] args) {
        String s = "hello";
        char[] array = s.toCharArray();
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }

        String s2 = String.format("%d,%d,%d", 2019, 9,14);
        System.out.println(s2);


    }

    public static void main6(String[] args) {
        String s = "hello";
        String s2 = s.toUpperCase();
        System.out.println(s2);


        String s3 = "Hel汉字lo9";
        System.out.println(s3.toLowerCase());
    }

    public static void main5(String[] args) {
        String s1 = String.valueOf(1234);
        String s2 = String.valueOf(12.34);
        String s3 = String.valueOf(true);
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);

        /*String s4 = String.valueOf(new Student("gaobo",13));
        System.out.println(s4);*/


        int data1 = Integer.parseInt("1234");
        double data2 = Double.parseDouble("12.34");
        System.out.println(data1+1);
        System.out.println(data2);
    }

    public static void main4(String[] args) {
        String s = "ababcabcd";
        //倒着往回的 第一个ab
        int index = s.lastIndexOf("abc",4);
        System.out.println(index);

       /* int index = s.indexOf('l');//默认是从0位置开始找
        System.out.println(index);


        index = s.indexOf('l',3);
        System.out.println(index);

        index = s.indexOf("ll",3);//默认是从0位置开始找
        System.out.println(index);
*/

        /*for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            System.out.println(ch);
        }*/


        /*char ch = s.charAt(5);
        System.out.println(ch);*/
        /*int[] array = {1,2,3,4,5};
        System.out.println(array.length);*/
    }

    public static void main3(String[] args) {
        String s1 = new String("aeF");
        String s2 = new String("aef");
        //比较字符串的大小
        System.out.println(s1.compareTo(s2));//s1和s2进行比较
        //1. 根据对应字符比较
        //2. 对应字符 无法比较出来 谁大 谁小 此时 就看长度
        System.out.println(s1.compareToIgnoreCase(s2));
    }

    public static void main2(String[] args) {

        String s1 = new String("hello");
        String s2 = new String("hello");
        String s3 = s1;
        System.out.println("=============");
        System.out.println(s1 == s2);//false
        System.out.println(s1 == s3);//true
        System.out.println(s2 == s3);//false
        System.out.println("========================");
        System.out.println(s1.equals(s2));//true
        System.out.println(s1.equals(s3));//true
        System.out.println(s2.equals(s3));//true
    }




    public static void main1(String[] args) {
        String str = "hello";
        String str2 = new String("world");
        char[] value = {'a','b','c'};
        String str3 = new String(value);


        System.out.println(str);
        System.out.println(str2);
        System.out.println(str3);
    }

    public int removeDuplicates(int[] nums) {
        int count =0 ;
        for(int i=0;i<nums.length-1;i++){
            if(nums[i]!=nums[i+1]){
                nums[count] = nums[i];
                count++;
            }
        }
        nums[count]=nums[nums.length-1];

        return count+1;
    }
}
